function mkselected(id, value)
{
    var loca = document.getElementById(id).options ;
	for(var i=0;i<loca.length;i++){
		if(loca[i].value == value)
			loca[i].selected = true ;
	}
}
function changestatus(value,id)
{
    $("#loadstatus"+id).html('<image src="'+url+'templates/images/loading1.gif">');
    $.post(url+"order/changestatus",{'status':value,'id':id},function(data)
    {
        $("#loadstatus"+id).html('');  
                                                     
    },'json');    
}
function loadstatic()
{
    $("#static").html('<image src="'+url+'templates/images/loading.gif">');
    $.post(url+"ajax/thongke",{},function(data)
    {
        $("#static").html(data);                                               
    });     
}

//Site config
function loadConfig()
{
    $("#config").html('<image src="'+url+'templates/images/loading.gif">');
    $.post(url+"siteconfig/config",{},function(data)
    {
        $("#config").html(data);                                               
    });    
}

//Member
function updatemember(id){
    $("#page").html('<image src="'+url+'templates/images/loading.gif">');
    $.post(url+"member/update/",{'id':id},function(data)
    {
        $("#page").html(data);                                               
    });     
}

//Publish
function publish(table,field,id,status)
{
    $("#publish"+id).html('<image src="'+url+'templates/images/loading.gif">');
    $.post(url+"ajax/publish",{'table':table,'field':field,'id':id,'status':status},function(data)
    {
        $("#publish"+id).html(data);                                               
    });
}
$(function(){
    $("#title").keyup(function()
    {
        var word=$(this).val();
        $.post(url+"ajax/getalias/",{'name':word},function(data)
        {
            $("#alias").val(data);
        });
        return false;
    });
});
function kodau(str){
	str= str.toLowerCase();
	str= str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g,"a");
	str= str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g,"e");
	str= str.replace(/ì|í|ị|ỉ|ĩ/g,"i");
	str= str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g,"o");
	str= str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g,"u");
	str= str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g,"y");
	str= str.replace(/đ/g,"d");
	str= str.replace(/!|@|\$|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\'| |\"|\&|\#|\[|\]|~/g,"-");
	str= str.replace(/-+-/g,"-"); //thay thế 2- thành 1-
	str= str.replace(/^\-+|\-+$/g,"");//cắt bỏ ký tự - ở đầu và cuối chuỗi
	return str;
}
function trit(a){
	console.log(a) ;
}
